package com.mc.developmentkit.config;

import android.app.Application;

import com.mc.developmentkit.bean.ConstantInfo;
import com.testin.agent.Bugout;
import com.testin.agent.BugoutConfig;

import org.xutils.x;

/**
 * Created by LeBron on 2016/12/23.
 */

public class MCFactory {

    private static MCFactory instance;

    private MCFactory() {
    }

    public static MCFactory getInstance() {
        if (null == instance) {
            instance = new MCFactory();
        }
        return instance;
    }

    public void init(ConstantInfo constant){
        MCConstant.wxAppId = constant.getWxAppId();
        MCConstant.bugOutAppId=constant.getBugOutAppId();
        MCConstant.UserRegisterUrl=constant.getUserRegisterUrl();
        MCConstant.UserPhoneRegisterUrl=constant.getUserPhoneRegisterUrl();
        MCConstant.UserGetPhoneCodeUrl=constant.getUserGetPhoneCodeUrl();
        MCConstant.AboutUsUrl=constant.getAboutUsInfoUrl();
        MCConstant.UserThirdLoginUrl=constant.getUserThirdLoginSubmitToServerUrl();
        MCConstant.UserLoginUrl=constant.getUserLoginUrl();
        MCConstant.UserForgetPassword=constant.getUserForgetPassowrdUrl();
        MCConstant.UserAliPayUrl=constant.getUserAliPayUrl();
        MCConstant.UserWFTPayUrl=constant.getUserWFTPayUrl();
        MCConstant.UserUpdatePasswordUrl=constant.getUserUpdatePasswordUrl();
        MCConstant.UserFeedBackUrl=constant.getUserFeedBackUrl();
        MCConstant.APPTopTusUrl=constant.getAPPTopTusUrl();
       // initMc(application);
       // initShareStyle(constant);
    }

    public void initShareStyle(ConstantInfo constant){
        ShareStyle.shareBGColor=constant.getShareBGColor();
        ShareStyle.sharePageNum=constant.getSharePageNum();
        ShareStyle.shareItemBGColor=constant.getShareItemBGColor();
        ShareStyle.shareLineNum=constant.getShareLineNum();
        ShareStyle.shareTextColor=constant.getShareTextColor();
        ShareStyle.shareTextSize=constant.getShareTextSize();
        ShareStyle.sharePosition=constant.getSharePosition();
    }

    public void initMc(Application application){
        //x.Ext.init(application);
        Bugout.init(application,MCConstant.getBugOutAppId(),"your channel ID");
        BugoutConfig config = new BugoutConfig.Builder(application)
                .withAppKey(MCConstant.getBugOutAppId())     // 您的应用的项目ID,如果已经在 Manifest 中配置则此处可略
//                .withAppChannel(cnl)     // 发布应用的渠道,如果已经在 Manifest 中配置则此处可略
//                .withUserInfo(userinfo)    // 用户信息-崩溃分析根据用户记录崩溃信息
                // .withDebugModel(true)    // 输出更多SDK的debug信息
                // .withErrorActivity(true)    // 发生崩溃时采集Activity信息
                // .withCollectNDKCrash(true) //  收集NDK崩溃信息
                .withOpenCrash(true)    // 收集崩溃信息开关
                // .withOpenEx(true)     // 是否收集异常信息
                // .withReportOnlyWifi(true)    // 仅在 WiFi 下上报崩溃信息
                // .withReportOnBack(true)    // 当APP在后台运行时,是否采集信息
                //.withQAMaster(true)    // 是否收集摇一摇反馈
                //.withCloseOption(false)   // 是否在摇一摇菜单展示‘关闭摇一摇选项’
                //  .withLogcat(true)  // 是否系统操作信息
                .build();
        Bugout.init(config);
    }

}
